HAL FLASH types migration ¶
This section provides information about the HAL FLASH types migration.
Note
In HAL1, the FLASH driver manages Flash memory operations.
In HAL2, depending on the device family, memory operations are managed either by the FLASH driver or by the NVM driver.
In this migration guide, when a type exists in both HAL2 FLASH and HAL2 NVM, the migration is illustrated using the HAL2 FLASH name. The same naming rule applies to HAL2 NVM.
Example: in HAL1,
FLASH_EccInfoTypeDeftype becomes:hal_flash_ecc_type_tandhal_flash_ecc_info_tin HAL2 FLASH driver.hal_nvm_ecc_type_tandhal_nvm_ecc_info_tin HAL2 NVM driver.
For NVM-based families, the NVM driver provides programming services similar to those of FLASH with minor differences:
There is no erase step for NVM memories.
Erase-by-address, page erase, bank erase, and FLASH mass erase remain FLASH-specific.
For NVM-based families, the only erase service that may be exposed is OBK erase, when that feature exists.
HAL FLASH erase type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef struct
{
uint32_t TypeErase;
uint32_t Banks;
uint32_t Sector;
uint32_t NbSectors;
uint32_t VoltageRange;
} FLASH_EraseInitTypeDef;
|
HAL1 FLASH_EraseInitTypeDef consolidated parameters (erase type, bank/page selection, number of pages) into a single init struct. HAL2 adopts direct granular erase APIs instead of a preparatory struct:
|
Related concepts:
HAL FLASH procedure type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef enum
{
FLASH_PROC_NONE = 0U,
FLASH_PROC_SECTERASE_BANK1,
FLASH_PROC_MASSERASE_BANK1,
FLASH_PROC_PROGRAM_BANK1,
FLASH_PROC_SECTERASE_BANK2,
FLASH_PROC_MASSERASE_BANK2,
FLASH_PROC_PROGRAM_BANK2,
FLASH_PROC_ALLBANK_MASSERASE
} FLASH_ProcedureTypeDef;
|
HAL1 FLASH_ProcedureTypeDef enumerated the internal FLASH operation state machine (e.g. NONE, PROGRAM, PROGRAM_LAST, PAGE_ERASE / SECTERASE, MASSERASE variants and sometimes bank-scoped forms) used by HAL to track an in-progress procedure. HAL2 removes this umbrella enumeration and introduce a handle that retains the context. Each operation is invoked explicitly via its dedicated API:
|
Related concept: Fully rework HAL Flash driver APIs.
HAL FLASH advanced option byte program type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef FLASH_AdvOBProgramInitTypeDef;
|
Removed / sequence changed. HAL1 monolithic advanced option bytes programming structure replaced by discrete HAL2 configuration APIs:
Each field formerly grouped in
|
Related concepts:
HAL FLASH block-based attributes type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef FLASH_BBAttributesTypeDef;
|
HAL1 FLASH_BBAttributesTypeDef aggregated boot / security / privilege attributes. HAL2 exposes fine-grained APIs instead of a packed structure:
Privilege / secure attributes are queried or configured per feature. |
Related concept: Fully rework HAL Flash driver APIs.
HAL FLASH CRC configuration type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef struct
{
uint32_t TypeCRC;
uint32_t BurstSize;
uint32_t Bank;
uint32_t Sector;
uint32_t NbSectors;
uint32_t CRCStartAddr;
uint32_t CRCEndAddr;
} FLASH_CRCInitTypeDef;
|
Removed / sequence changed.Replaced by granular CRC configuration APIs detailed here. |
Related concept: Fully rework HAL Flash driver APIs.
HAL FLASH cache type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef enum
{
FLASH_CACHE_DISABLED = 0,
FLASH_CACHE_ICACHE_ENABLED,
FLASH_CACHE_DCACHE_ENABLED,
FLASH_CACHE_ICACHE_DCACHE_ENABLED
} FLASH_CacheTypeDef;
|
typedef enum
{
HAL_FLASH_ITF_CACHE_DISABLED
HAL_FLASH_ITF_CACHE_ENABLED
} hal_flash_itf_cache_status_t;
|
Related concepts:
HAL FLASH ECC info type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef struct
{
uint32_t Area; /*!< Area from which an ECC was detected.
This parameter can be a value of @ref FLASHEx_ECC_Area */
uint32_t Address; /*!< ECC error address */
uint32_t Data; /*!< ECC failing data */
} FLASH_EccInfoTypeDef;
|
typedef enum
{
HAL_FLASH_ECC_FAIL_NONE, /*!< FLASH ECC fail none */
HAL_FLASH_ECC_SINGLE, /*!< FLASH ECC fail ECC single error correction and detection */
HAL_FLASH_ECC_DOUBLE, /*!< FLASH ECC fail ECC double error correction and detection */
HAL_FLASH_ECC_TRIPLE_ERROR, /*!< FLASH ECC fail ECC triple error detection */
} hal_flash_ecc_type_t;
typedef struct
{
hal_flash_ecc_type_t ecc_fail_type; /*!< FLASH ECC fail type */
uint32_t ecc_fail_addr; /*!< FLASH ECC fail address */
uint32_t data; /*!< FLASH ECC data */
hal_flash_ecc_status_t status; /*!< FLASH ECC status */
} hal_flash_ecc_info_t;
|
Related concept: Fully rework HAL Flash driver APIs.
HAL FLASH HDP extension type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef FLASH_HDPExtensionTypeDef;
|
HAL1 FLASH_HDPExtensionTypeDef packed extension configuration for Hide Protection (HDP) area (start page, length, access protection mode, level transitions). HAL2 provides granular APIs instead of a struct:
Each previous struct field is now represented by an explicit call or small status enumeration. no replacement typedef exists in HAL2. |
Related concepts:
HAL FLASH option bytes program type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef FLASH_OBProgramInitTypeDef;
|
HAL1 FLASH_OBProgramInitTypeDef aggregated multiple option bytes fields (BORLevel, UserConfig bits, WRPArea, RDPLevel, NV state, Secure/Privilege flags, HDP area parameters, SRAM ECC, Bank swap, debug authentication, pull-up config, OEM key provisioning, etc) in a single programming structure. HAL2 decomposes each concern into fine-grained setter/getter or enable/disable/status APIs. Use the dedicated calls:
|
Related concept: Fully rework HAL Flash driver APIs.
HAL FLASH operation type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef FLASH_OperationTypeDef;
|
typedef enum
{
HAL_FLASH_INTERRUPTED_NO_OPERATION,
HAL_FLASH_INTERRUPTED_SINGLE_WRITE,
HAL_FLASH_INTERRUPTED_PAGE_ERASE,
HAL_FLASH_INTERRUPTED_BANK_ERASE,
HAL_FLASH_INTERRUPTED_MASS_ERASE,
HAL_FLASH_INTERRUPTED_OB_CHANGE
} hal_flash_interrupted_operation_t;
typedef struct
{
uint32_t addr; /*!< FLASH interrupted operation address */
hal_flash_interrupted_operation_t operation; /*!< FLASH interrupted operation code */
} hal_flash_interrupted_by_reset_operation_info_t;
|
Related concept: Fully rework HAL Flash driver APIs.
HAL FLASH handle type definition ¶
|
HAL1 |
HAL2 |
|---|---|
typedef FLASH_ProcessTypeDef;
|
HAL1 FLASH_ProcessTypeDef was an internal/global context structure (procedure enum, bank/page indices, address, remaining pages, error code, lock state). HAL2 hides this state entirely. each API call carries full intent (page number, bank, address range, key type, etc.) and returns a status (hal_status_t).
Longer operations in IT mode signal completion or errors through callbacks (e.g.
Error and progress inspection no longer require exposing a mutable global process struct. |
Related concept: Fully rework HAL Flash driver APIs.